package org.dong.provider;

import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.dong.api.GreetingsService;
import org.dong.provider.api.GreetingsServiceImpl;

import java.util.concurrent.CountDownLatch;

public class ProviderApplication {
    private static String zookeeperHost = System.getProperty("zookeeper.host","127.0.0.1");

    public static void main(String[] args) throws InterruptedException {
        ServiceConfig<GreetingsService> serviceConfig = new ServiceConfig<>();
        serviceConfig.setApplication(new ApplicationConfig("first-dubbo-provider"));
        serviceConfig.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
        serviceConfig.setInterface(GreetingsService.class);
        serviceConfig.setRef(new GreetingsServiceImpl());
        serviceConfig.export();

        System.out.println("dubbo service started");
        new CountDownLatch(1).await();
    }
}
